//
//  NotificationHelp.m
//  Common
//
//  Created by guoshiqing on 2018/5/19.
//  Copyright © 2018年 www.bitkinetic.com. All rights reserved.
//

#import "NotificationHelp.h"

/** 系统级 */
NSString *const NotificationDidEnterBackground = @"NotificationDidEnterBackground";
NSString *const NotificationWillEnterForeground = @"NotificationWillEnterForeground";
NSString *const NotificationGo2MainTBC = @"NotificationGo2MainTBC";
NSString *const NotificationGo2LoginVC = @"NotificationGo2LoginVC";
NSString *const NotificationLoginSuccess = @"NotificationLoginSuccess";
NSString *const NotificationAutoLoginSuccess = @"NotificationAutoLoginSuccess";

// 消息中心产生了新的消息
NSString *const NotificationMsgCenterHaveNewMsg = @"NotificationMsgCenterHaveNewMsg";


@implementation NotificationHelp

+ (void)postNotification:(NSString *)notification object:(id)object
{
    if (nil == notification) return;
    
    dispatch_async(dispatch_get_main_queue(), ^{
        [[NSNotificationCenter defaultCenter] postNotificationName:notification object:object];
    });
}

+ (void)postNotification:(NSString*)notification userInfo:(NSDictionary*)userInfo object:(id)object
{
    dispatch_async(dispatch_get_main_queue(), ^{
        [[NSNotificationCenter defaultCenter] postNotificationName:notification object:object userInfo:userInfo];
    });
}

+ (id)addNotification:(NSString*)notification object:(id)object usingBlock:(void (^)(NSNotification *note))block
{
    id observer = [[NSNotificationCenter defaultCenter] addObserverForName:notification object:object queue:[NSOperationQueue mainQueue] usingBlock:block];;
    return observer;
}

+ (id)addNotification:(NSString*)notification usingBlock:(void (^)(NSNotification *note))block
{
    return [[NSNotificationCenter defaultCenter] addObserverForName:notification object:nil queue:[NSOperationQueue mainQueue] usingBlock:block];
}

@end
